package com.yanqu.road.server.cmd.activity.peakseacraft;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.PeakSeacraftProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.peakseacraft.PeakSeacraftMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;

import java.util.List;

/**
 * @Description
 */
@Cmd(code = CrossProtocol.C_PEAK_SEACRAFT_GUESS, desc = "海上争霸 南海丝路 竞猜")
public class CrossPeakSeacraftGuessCmd extends CrossUnionCommand {

    long userId;
    int activityId;
    String ownUnionId;
    List<String> unionList;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        PeakSeacraftProto.PeakSeacraftGuessGameToCrossMsg reqMsg = PeakSeacraftProto.PeakSeacraftGuessGameToCrossMsg.parseFrom(packet.getBytes());
        userId = packet.getPlayerId();
        activityId = reqMsg.getActivityId();
        ownUnionId = reqMsg.getUnionId();
        unionList = reqMsg.getStcMsg().getUnionListList();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(ClientProtocol.U_PEAK_SEACRAFT_GUESS,
                PeakSeacraftMgr.guess(activityId, userId, serverId, ownUnionId, unionList));
        MessageHelper.sendPacket(serverId, userId, pbMsg);
    }

    @Override
    public void sendData() {

    }
}
